package com.zhentao.controller;

import com.zhentao.pojo.TbItem;
import com.zhentao.service.TbItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("item")
public class ItemController {
    @Autowired
    private TbItemService service;
    @RequestMapping("update")
    public String update(Integer id,Integer num){
        TbItem tb = service.getById(id);
        tb.setStock(tb.getStock()-num);
        service.updateById(tb);
        return "修改成功";
    }
    @RequestMapping("findPrice")
    public Double findPrice(Integer id){
        Double price = service.getById(id).getPrice();
        System.err.println(11111111);
        return price;
    }
}
